<div id="logged_in">

	<fb:login-button autologoutlink="true"></fb:login-button>
    <fb:like></fb:like>


    <div id="fb-root_status"></div>
    <script type="text/javascript">
      window.fbAsyncInit = function() {
        FB.init({appId: '188344027872191', status: true, cookie: true,
                 xfbml: true});
      };
      (function() {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
          '//connect.facebook.net/sv_SE/all.js';
        e.async = true;
        document.getElementById('fb-root_status').appendChild(e);
      }());
    </script>

<script>
	FB.Event.subscribe('auth.login', function(response) {
  // do something with response.session
});
</script>

<script type="text/javascript">
FB.login(function(response) {
  if (response.session) {
  document.alert("logged in");
  
  var postId = '188344027872191';
	FB.api(postId, 'delete', function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post was deleted');
  }
});
    // user successfully logged in
  } else {
  alert("not logged in");
    // user cancelled login
  }
});

FB.api('/f8/posts', { limit: 3 }, function(response) {
  for (var i=0, l=response.length; i<l; i++) {
    var post = response[i];
    if (post.message) {
      alert('Message: ' + post.message);
    } else if (post.attachment && post.attachment.name) {
      alert('Attachment: ' + post.attachment.name);
    }
  }
});

</script>

</div>